From 88d7624911a372350d1cf19eef22ac1f91e870ca Mon Sep 17 00:00:00 2001 From: robertl Date: Sat, 15 Apr 2006 19:54:53 +0000 Subject: [PATCH] Use radians to get results that are at least vaguely believable... --- gpsbabel/route.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gpsbabel/route.c b/gpsbabel/route.c index b13a05da1..65cae1264 100644 --- a/gpsbabel/route.c +++ b/gpsbabel/route.c @@ -456,12 +456,18 @@ void track_recompute(route_head *trk) QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) { this = (waypoint *)elem; - this->course = heading(prev->latitude, prev->longitude, - this->latitude, this->longitude); - this->speed = radtometers(gcdist( - RAD(prev->latitude), RAD(prev->longitude), - RAD(this->latitude), RAD(this->longitude))) / + double tlat, tlon, plat, plon, dist; + /* gcdist and headin want radians, not degrees */ + tlat = RAD(this->latitude); + tlon = RAD(this->longitude); + plat = RAD(prev->latitude); + plon = RAD(prev->longitude); + this->course = DEG(heading(plat, plon, + tlat, tlon)); + dist = radtometers(gcdist(plat, plon, tlat, tlon)); + this->speed = dist / labs(this->creation_time - prev->creation_time); + prev = this; } } -- 2.30.2